# coding=utf-8
# Time : 2020/10/19 19:17
# Author : huxin

import logging
import time
from RootPath import RootPath
import os


def logger():
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.INFO)
    #获取日志名
    logFileName = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '.log'
    logFile = os.path.join(RootPath.getRootPath(),"log/") + logFileName
    handler = logging.FileHandler(logFile,encoding='utf-8')

    logging_format = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(funcName)s : %(message)s')
    handler.setFormatter(logging_format)
    logger.addHandler(handler)
    return logger


